<template>
	<view class="camera-view" :style="{'height': caremaHeight + 'px'}">
        <view v-if="!isFlash">
            <camera device-position="back" flash="auto" class="camera" mode="scanCode" :flash="flash" @scancode="scanCode"></camera>

            <canvas class="scan-canvas" canvas-id="scanCanvas"></canvas>

            <!--<canvas class="scan-canvas-photo" :style="{'width':  + 'px','height': photoHeight + 'px'}" canvas-id="scanPhoto"></canvas>-->
            <canvas class="scan-canvas-photo" style="width:100px;height:100px" canvas-id="scanPhoto"></canvas>

            <view class="scan-list" v-if="isContinuous && scanList.length > 0 && !showDetail && showList">
                <!--<view class="list-view" :style="{'height': caremaHeight / 3 + 'px'}">-->
                <view class="list-view" style="height:800rpx;">
                    <view class="scan-item" v-for="(item, index) in scanList" :key="index">
                    <!--<view class="scan-item" v-for="(item, index) in scanList" :key="index">-->
                        <view class="icon-view">
                            <view class="iconfont icon-delete" @click.stop="delItem(index)"></view>
                        </view>
                        <view style="width: 50%;">
                            <view class="text" @click="showDetailFunc(item)">{{item.name}}</view>
                        </view>
                        <!--<image class="icon" :src="item.url"></image>-->
                        <view style="display: flex;width: 20%;">
                            <!--<view class="icon-view3">-->
                                <!--<view class="iconfont icon-xia" @click.stop="jian(item)"></view>-->
                            <!--</view>-->
                            <view>
                                <input style=" text-align: center;" v-model="item.num" type="number" pattern="[0-9]*" />
                            </view>
                            <!--<view class="icon-view2">-->
                                <!--<view class="iconfont icon-shang" @click.stop="zen(item)"></view>-->
                            <!--</view>-->
                        </view>
                        <view style="display: flex;width: 20%;">
                            <view class="text icon-view4">
                                {{item.dw}}
                            </view>
                        </view>
                    </view>
                </view>
                <view class="btn-view">
                    <view class="btn del" @click="clearList">全部清除</view>
                    <view class="btn2 del2" @click="successList">扫码完成</view>
                </view>
            </view>

            <!--<view class="scan-list" v-if="isContinuous && scanList.length > 0 && !showDetail && showList">-->
                <!--<view class="list-view" :style="{'height': caremaHeight / 3 + 'px'}">-->
                    <!--<view class="scan-item" v-for="(item, index) in scanList" :key="index" @click="showDetailFunc(item)">-->
                        <!--<view class="text">{{item.text}}</view>-->
                        <!--&lt;!&ndash;<image class="icon" :src="item.url"></image>&ndash;&gt;-->
                        <!--<view class="icon-view">-->
                            <!--<view class="iconfont icon-delete" @click.stop="delItem(index)"></view>-->
                        <!--</view>-->
                    <!--</view>-->
                <!--</view>-->
                <!--<view class="btn-view">-->
                    <!--<view class="btn del" @click="clearList">全部清除</view>-->
                    <!--<view class="btn2 del2" @click="successList">扫码完成</view>-->
                <!--</view>-->
            <!--</view>-->

            <!--<view class="dialog-view" v-if="((scanItem.text || scanItem.url) && !isContinuous) || showDetail">-->
                <!--<view class="dialog">-->
                    <!--<view class="result" v-if="scanItem.text">-->
                        <!--<view class="label">扫码结果:</view>-->
                        <!--<text class="value">{{scanItem.text}}</text>-->
                    <!--</view>-->

                    <!--&lt;!&ndash;<view class="result" v-if="scanItem.url">&ndash;&gt;-->
                    <!--&lt;!&ndash;<view class="label">扫码图片:</view>&ndash;&gt;-->
                    <!--&lt;!&ndash;<view class="image-view">&ndash;&gt;-->
                    <!--&lt;!&ndash;<image class="photo" :src="scanItem.url" mode="widthFix"></image>&ndash;&gt;-->
                    <!--&lt;!&ndash;</view>&ndash;&gt;-->
                    <!--&lt;!&ndash;</view>&ndash;&gt;-->
                <!--</view>-->

                <!--<view class="iconfont icon-clear" @click="reset"></view>-->
            <!--</view>-->

            <!--需要-->
            <view class="dialog-view" v-if="showDetail">
                <view class="dialog">
                    <view class="result" v-if="scanList[0].name">
                        <view class="label"  style="margin-bottom: 20rpx;" >扫码结果:</view>
                        <text class="value">{{scanList[0].name}}</text>
                        <view style="display: flex;margin-top: 20rpx;">
                            <view style="width: 20%">
                                <span>数量：</span>
                            </view>
                            <view style="width: 89%">
                                <input style=" text-align: center;" v-model="scanList[0].num" type="number" pattern="[0-9]*" />
                            </view>
                        </view>
                        <view v-if="!showDetailType" style="display: flex;margin-top: 40rpx;">
                            <button style="background: #e02b2b;color: #ffffff;" @click="qx">移除</button>
                            <button style="background: #1164e0;color: #ffffff;" @click="reset">添加</button>
                        </view>
                    </view>
                    <!--<view class="result" v-if="scanItem.url">-->
                    <!--<view class="label">扫码图片:</view>-->
                    <!--<view class="image-view">-->
                    <!--<image class="photo" :src="scanItem.url" mode="widthFix"></image>-->
                    <!--</view>-->
                    <!--</view>-->
                </view>
                <view v-if="showDetailType" class="iconfont icon-clear" @click="reset"></view>
            </view>
            <!--<view class="result" v-if="scanItem.url">-->
            <!--<view class="label">扫码图片:</view>-->
            <!--<view class="image-view">-->
            <!--<image class="photo" :src="scanItem.url" mode="widthFix"></image>-->
            <!--</view>-->
            <!--</view>-->
        </view>
        <view class="dialog-view2" v-if="isFlash">
            <view class="dialog">
                <view style="display: flex;margin-top: 20rpx;">
                    <view style="text-align: left;width: 25%"><span style="color: red;">*</span>联系方式:</view>
                    <view style="text-align: center;width: 75%"><input style=" text-align: center;" v-model="contactPhone" type="number" pattern="[0-9]*" /></view>
                </view>

                <view style="display: flex;margin-top: 20rpx;">
                    <view style="width: 25%"><span style="color: red;">*</span>地址:</view>
                    <view style="text-align: center;width: 75%">
                        <input style=" text-align: center;" v-model="address" />
                    </view>
                </view>
                <view style="margin-top: 20rpx;" >扫码结果:</view>
                <view style="margin-top: 10rpx;" >
                    <view style="display: flex;">
                        <view style="text-align: center;width: 10%">序号</view>
                        <view style="text-align: center;width: 30%">品名</view>
                        <view style="text-align: center;width: 20%">单位</view>
                        <view style="text-align: center;width: 20%">数量</view>
                        <view style="text-align: center;width: 20%">单格</view>
                    </view>
                </view>
                <view class="scan-list2">
                    <view class="list-view">
                        <view class="scan-item" v-for="(item, index) in scanList" :key="index">
                            <view style="width: 10%">
                                <view class="text"  style="text-align: center;">{{index+1}}</view>
                            </view>
                            <view style="width: 30%">
                                <view class="text" style="text-align: center;" @click="showDetailFunc(item)">{{item.name}}</view>
                            </view>
                            <view style="width: 20%;">
                                <view class="text" style="text-align: center;">
                                    {{item.dw}}
                                </view>
                            </view>
                            <view  style="width: 20%;">
                                <view class="text" style="text-align: center;">
                                    {{item.num}}
                                </view>
                            </view>
                            <view style="width: 20%;">
                                <view class="text" style="text-align: center;">
                                    {{item.price}}
                                </view>
                            </view>
                        </view>
                    </view>
                </view>
                <view style="display: flex;margin-top: 20rpx;">
                   总计：{{zonsu}}
                </view>
                <view style="display: flex;margin-top: 20rpx;">
                    <button style="background: #e02b2b;color: #ffffff;" @click="black">返回</button>
                    <button v-if="isButton" style="background: #1164e0;color: #ffffff;" @click="dayin">打印</button>
                    <button v-else style="background: #979797;color: #ffffff;">打印中...</button>
                </view>
            </view>
        </view>
    </view>
</template>

<!--<script src="./index.js" type="text/javascript"></script>-->
<script>
	// import { smget } from '../../api/sm'
	import { mp3 } from '../../static/tipMp3/smok.mp3'
	export default {
		name: 'ws-carema',
		props: {
			getPhoto: { // 是否返回图片
				type: Boolean,
				default: true
			},
			isContinuous: { // 是否连续扫码
				type: Boolean,
				default: true
			},
			scanInterval: { // 连续扫码间隔
				type: Number,
				default: 2000
			},
			checkRepeat: { // 是否判断重复扫码
				type: Boolean,
				default: true
			},
			showList: { // 是否显示连续扫码列表
				type: Boolean,
				default: true
			}
		},
		data() {
			return {
				flash: false,
				isFlash: false,
                isButton: false,
				exPid: null,
				caremaHeight: 0,
				scanItem: {
					text: '', // 扫码内容
					name: '', // 扫码简称
					dw: '', // 扫码单位
					url: '', // 扫码url
					price: '', // 扫码价格
                    zj: '', // 扫码价格
					num: 1 // 扫码数量
				},
				listener: null,
                address: undefined,
                contactPhone: undefined,
				beignGetPhoto: false,
				photoWidth: 500,
				photoHeight: 500,
				beginScan: true,
				showDetail: false,
				showDetailType: false,
				userInfo: null,
                scanList: [],
				// scanList: [
				//     {text: 'sku001',name: '排水管材（乐业系列）dn50×1.8',dw: '米',num: 12,price:'10.10',url: ''},
				//     {text: 'sku001',name: '排水管材（乐业系列）dn50×1.8',dw: '米',num: 12,price:'120.10',url: ''},
				//     {text: 'sku001',name: '排水管材（乐业系列）dn50×1.8',dw: '米',num: 12,price:'130.10',url: ''},
				//     {text: 'sku001',name: '排水管材（乐业系列）dn50×1.8',dw: '米',num: 12,price:'150.10',url: ''},
				//     {text: 'sku001',name: '排水管材（乐业系列）dn50×1.8',dw: '米',num: 12,price:'160.10',url: ''},
				//     {text: 'sku001',name: '排水管材（乐业系列）dn50×1.8',dw: '米',num: 12,price:'180.10',url: ''},
				//     {text: 'sku001',name: '排水管材（乐业系列）dn50×1.8',dw: '米',num: 12,price:'110.10',url: ''},
				//     {text: 'sku001',name: '排水管材（乐业系列）dn50×1.8',dw: '米',num: 12,price:'20.10',url: ''},
				//     {text: 'sku001',name: '排水管材（乐业系列）dn50×1.8',dw: '米',num: 12,price:'30.10',url: ''},
				//     {text: 'sku001',name: '排水管材（乐业系列）dn50×1.8',dw: '米',num: 12,price:'40.10',url: ''},
				//     {text: 'sku001',name: '排水管材（乐业系列）dn50×1.8',dw: '米',num: 12,price:'100.10',url: ''},
				//     {text: 'sku001',name: '排水管材（乐业系列）dn50×1.8',dw: '米',num: 12,price:'20.10',url: ''},
				//     {text: 'sku001',name: '排水管材（乐业系列）dn50×1.8',dw: '米',num: 12,price:'90.10',url: ''},
				//     {text: 'sku001',name: '排水管材（乐业系列）dn50×1.8',dw: '米',num: 12,price:'50.10',url: ''},
				//     {text: 'sku001',name: '排水管材（乐业系列）dn50×1.8',dw: '米',num: 12,price:'160.10',url: ''},
				//     {text: 'sku001',name: '排水管材（乐业系列）dn50×1.8',dw: '米',num: 12,price:'100.10',url: ''},
				//     {text: 'sku001',name: '排水管材（乐业系列）dn50×1.8',dw: '米',num: 12,price:'16.10',url: ''},
				//     {text: 'sku001',name: '排水管材（乐业系列）dn50×1.8',dw: '米',num: 12,price:'13.10',url: ''},
				//     {text: 'sku001',name: '排水管材（乐业系列）dn50×1.8',dw: '米',num: 12,price:'10.10',url: ''},
				//     {text: 'sku001',name: '排水管材（乐业系列）dn50×1.8',dw: '米',num: 12,price:'60.10',url: ''},
				//     {text: 'sku001',name: '排水管材（乐业系列）dn50×1.8',dw: '米',num: 12,price:'80.10',url: ''},
				//     {text: 'sku002',name: '冷水管S5',dw: '个',num: 30,price:'9.01',url: ''}
                // ], // 连续扫码记录
				zonsu: 0.00,
				audio: null
			}
		},
		mounted() {
			// if (this.getPhoto) {
			// 	this.startTacking()
			// }
			this.drawCanvas()
            this.userInfo = uni.getStorageSync('userInfo').value;
		},
		methods: {
            black(){
                this.isFlash = false
            },
            dayin(){
                var that = this
                //加入判断
                if(that.address!=undefined&&that.contactPhone!=undefined){
                    that.isButton = false
                    uni.request({
                        data: {
                            userName: that.userInfo.nickName,
                            phone: that.userInfo.phone,
                            address:that.address,
                            contactPhone: that.contactPhone,
                            productZj: that.zonsu,
                            type: that.userInfo.reserved3
                        },
                        method: 'POST',
                        url: that.bash + '/fApi/record/addEx',
                        success: res => {
                            if(res.data.code == 200) {
                                var i = 1
                                that.exPid = res.data.data.id
                                that.scanList.forEach(function (item) {
                                    uni.request({
                                        data: {
                                            productExid: res.data.data.id,// id
                                            productName: item.name,// 扫码简称
                                            productPrice: item.price,// 扫码价格
                                            productZj:item.zj,// 扫码总价格
                                            num: item.num,// 扫码数量
                                            unit: item.dw,// 扫码单位
                                            retainfield1: item.text,// 扫码内容SKU
                                            retainfield2: i++,// 排序
                                            createUser: that.userInfo.phone,// 创建者
                                            type: that.userInfo.reserved3 // 扫码类型
                                        },
                                        method: 'POST',
                                        url: that.bash + '/fApi/exproduct/addExProduct',
                                        success: res => {
                                        }
                                    })
                                })
                            }else{
                                uni.showToast({
                                    title: '新增失败!',
                                    icon: 'none'
                                })
                                return
                            }
                        }
                    })
                    uni.showToast({
                        title: '打印加载中!',
                        icon: 'none'
                    })
                    setTimeout(function () {
                        uni.request({
                            data: {
                                id: that.exPid,// id
                                userName: that.userInfo.nickName,
                                phone: that.userInfo.phone,
                                address:that.address,
                                contactPhone: that.contactPhone,
                                productZj: that.zonsu,
                                type: that.userInfo.reserved3
                            },
                            method: 'POST',
                            url: that.bash + '/fApi/exproduct/dyRecord',
                            success: res => {
                                if(res.data.code == 200) {
                                    that.exPid = undefined
                                    that.isFlash = false
                                    that.isButton = true
                                    that.isButton = false
                                    that.address = undefined
                                    that.contactPhone = undefined
                                    that.scanList = []
                                }else{
                                    uni.showToast({
                                        title: '打印失败!',
                                        icon: 'none'
                                    })
                                }
                            }
                        })
                    }, 2000);
                }else{
                    uni.showToast({
                        title: '请填写联系方式和地址!',
                        icon: 'none'
                    })
                    return
                }
            },
			jian(item) {
				if(item.num>0){
					item.num = (item.num*10-10)/10;
				}
			},
			zen(item) {
				item.num = (item.num*10+10)/10;
			},
			delItem(index) {
				uni.showModal({
					title: '温馨提示',
					content: '确认删除此条扫码记录?',
					showCancel: true,
					confirmColor: '#51A830',
					cancelColor: '#ababab',
					success: res => {
						if (res.confirm) {
							this.scanList.splice(index, 1)
						}
					}
				})
			},
			clearList() {
				uni.showModal({
					title: '温馨提示',
					content: '确认删除所有扫码记录?',
					showCancel: true,
					confirmColor: '#51A830',
					cancelColor: '#ababab',
					success: res => {
						if (res.confirm) {
							this.scanList = []
						}
					}
				})
			},
			successList() {
				let that = this
                that.zonsu = 0.00
				var zj = 0.00
                that.scanList.forEach(function (item) {
                    zj = (item.num*item.price).toFixed(5)*100000;
                    item.zj = zj/100000;
                    that.zonsu += zj
                })
                that.zonsu = that.zonsu/100000;
                that.isFlash = true;
                that.isButton = true;
            },
			// getCurrentTime() {
			//     //获取当前时间并打印
			//     let yy = new Date().getFullYear();
			//     let mm = new Date().getMonth()+1;
			//     mm = mm<10 ? '0'+mm : mm;
			//     let dd = new Date().getDate();
			//     dd = dd<10 ? '0'+dd : dd;
			//     let hh = new Date().getHours();
			//     let mf = new Date().getMinutes()<10 ? '0'+new Date().getMinutes() : new Date().getMinutes();
			//     let ss = new Date().getSeconds()<10 ? '0'+new Date().getSeconds() : new Date().getSeconds();
			//     return yy+mm+dd+hh+mf+ss;
			// },
			reset() {
				this.scanItem = {
					text: '',
					name: '',
					dw: '',
					num: 1,
					price:'',
                    zj:'',
					url: ''
				}
				this.beignGetPhoto = false
				this.showDetail = false
				this.showDetailType = false
				this.$emit('scanItem', this.scanItem)
			},
			qx() {
				this.scanItem = {
					text: '',
					name: '',
					dw: '',
					num: 1,
					price: '', // 扫码价格
					url: ''
				}
				this.beignGetPhoto = false
				this.showDetail = false
				this.showDetailType = false
				this.$emit('scanItem', this.scanItem)
				this.scanList.splice(0, 1)
			},
			checkIsRepeat(text) {
				const index = this.scanList.findIndex(v => v.text === text)
				return index > -1
			},
			audioPlayFuc() {
				if (!this.audio) {
					this.audio = uni.createInnerAudioContext()
				}
				this.audio.src = "../../static/tipMp3/smok.mp3"
				this.audio.play()
				// 音频自然播放结束
				this.audio.onEnded(() => {
					console.log('播放结束')
				})
				// 音频播放错误处理
				this.audio.onError(() => {
					console.log('播放出错')
				})
			},
			scanCode(e) {
				const text = e.detail.result
				if (this.isContinuous) {
					if (!this.beginScan || this.showDetail) {
						return
					}

					this.beginScan = false
					setTimeout(() => {
						this.beginScan = true
					}, this.scanInterval)

					const isHave = this.checkIsRepeat(text)
					if (isHave) {
						uni.showToast({
							title: '重复扫码!',
							icon: 'none'
						})
						return
					}

					this.audioPlayFuc()

					var that = this;
					//加入判断
					uni.request({
						method: 'GET',
						url: that.bash + '/fApi/exproduct/listSku?sku='+text,
						success: res => {
							if(res.data.code == 200) {
								if(res.data.data == null||res.data.data == "null"||res.data.data == undefined||res.data.data == "undefined"){
									uni.showToast({
										title: '无效sku!',
										icon: 'none'
									})
									return
								}
								var price = res.data.data.retailPrice;
								var type = '01';
								if(that.userInfo!=null){
									type = that.userInfo.reserved3;
								}else{
									that.userInfo =  uni.getStorageSync('userInfo');
									type = that.userInfo.reserved3;
								}
								switch (type) {
									case "02":
										price = res.data.data.wholesalePrice;
										break;
									case "03":
										price = res.data.data.orderedPrice;
										break;
									case "04":
										price = res.data.data.frockPrice;
										break;
									case "05":
										price = res.data.data.engineeringPrice;
										break;
								}
								that.scanItem = {
									text,
									name:res.data.data.alias,
									dw:res.data.data.productDw,
									num:1,
									price:price,
                                    zj:price,
									url: ''
								}
								that.scanList.unshift(that.scanItem)
								that.$emit('scanItem', that.scanItem)
								that.$emit('scanList', that.scanList)
								that.showDetail = true;
								that.showDetailType = false;
								return
							}else{
								uni.showToast({
									title: '获取商品数据失败!',
									icon: 'none'
								})
								return
							}
						}
					})

					// if (!that.getPhoto) {
					// 	that.scanList.unshift(that.scanItem)
					// 	that.$emit('scanItem', that.scanItem)
					// 	that.$emit('scanList', that.scanList)
					// }

				} else {
					// 单个扫码：如果已扫码则停止扫码，重新扫码调用this.reset()方法
					if (this.scanItem.text !== '') {
						return
					}

					this.audioPlayFuc()

					var that = this;
					//加入判断
					uni.request({
						method: 'GET',
						url: that.bash + '/fApi/exproduct/listSku?sku='+this.scanItem.text,
						success: res => {
							if(res.data.code == 200) {
								var price = res.data.data.retailPrice;
								var type = '01';
								if(that.userInfo!=null){
									type = that.userInfo.reserved3;
								}else{
									that.userInfo =  uni.getStorageSync('userInfo');
									type = that.userInfo.reserved3;
								}
								switch (type) {
									case "02":
										price = res.data.data.wholesalePrice;
										break;
									case "03":
										price = res.data.data.orderedPrice;
										break;
									case "04":
										price = res.data.data.frockPrice;
										break;
									case "05":
										price = res.data.data.engineeringPrice;
										break;
								}
								that.scanItem = {
									text,
									name:res.data.data.alias,
									dw:res.data.data.productDw,
									num:1,
									price:price,
                                    zj:price,
									url: ''
								}
								that.$emit('scanItem', that.scanItem)
							}
						}
					})

					// if (!that.getPhoto) {
					// 	that.$emit('scanItem', that.scanItem)
					// }
				}

				this.beignGetPhoto = true
			},
			drawCanvas() {
				const res = uni.getSystemInfoSync()
				this.caremaHeight = this.height ? this.height : res.windowHeight
				// 画布绘画区域
				const width = res.windowWidth
				const height = res.windowHeight

				// 画布清除部分(中间扫描透明框)
				const left = uni.upx2px(20)
				const top = uni.upx2px(20)
				const clearWidth = width - 2 * left
				const clearHeight = height - 2 * top

				// 拐角尺寸(长度，粗细, 颜色)
				const length = uni.upx2px(40)
				const stoke = uni.upx2px(6)
				const color = '#ffffff'

				const ctx = uni.createCanvasContext('scanCanvas', this)

				// 扫描区域
				ctx.setGlobalAlpha(0.3)
				ctx.setFillStyle('black')
				ctx.fillRect(0, 0, width, height)
				ctx.clearRect(left, top, clearWidth, clearHeight)

				// 扫描拐角(左上)
				ctx.setGlobalAlpha(1)
				ctx.rect(left, top - (stoke / 2), length, stoke)
				ctx.setFillStyle(color)
				ctx.fill()
				ctx.rect(left - (stoke / 2), top - (stoke / 2), stoke, length)
				ctx.setFillStyle(color)
				ctx.fill()

				// 扫描拐角(右上)
				ctx.rect(left + clearWidth - length, top - (stoke / 2), length, stoke)
				ctx.setFillStyle(color)
				ctx.fill()
				ctx.rect(left + clearWidth - (stoke / 2), top - (stoke / 2), stoke, length)
				ctx.setFillStyle(color)
				ctx.fill()

				// 扫描拐角(左下)
				ctx.rect(left - (stoke / 2), top + clearHeight - (stoke / 2), length, stoke)
				ctx.setFillStyle(color)
				ctx.fill()
				ctx.rect(left - (stoke / 2), top + clearHeight - length, stoke, length)
				ctx.setFillStyle(color)
				ctx.fill()

				// 扫描拐角(右下)
				ctx.rect(left + clearWidth - length + (stoke / 2), top + clearHeight - (stoke / 2), length, stoke)
				ctx.setFillStyle(color)
				ctx.fill()
				ctx.rect(left + clearWidth - (stoke / 2), top + clearHeight - length, stoke, length)
				ctx.setFillStyle(color)
				ctx.fill()

				ctx.draw()
			},
			// 图片帧数据
			startTacking() {
				const that = this
				const context = uni.createCameraContext()
				if (!context.onCameraFrame) {
					uni.showToast({
						title: '基础库 2.7.0 开始支持.',
						icon: 'none'
					})
					return
				}
				this.listener = context.onCameraFrame(async function (res) {
					if (that.beignGetPhoto && that.getPhoto) {
						uni.showLoading({
							title: '获取图片中'
						})
						that.photoWidth = res.width
						that.photoHeight = res.height
						that.beignGetPhoto = false
						const data = new Uint8Array(res.data)
						const clamped = new Uint8ClampedArray(data)
						uni.canvasPutImageData({
							canvasId: 'scanPhoto',
							x: 0,
							y: 0,
							width: res.width,
							height: res.height,
							fileType: 'jpg',
							quality: 0.9,
							data: clamped,
							success (res) {
								uni.canvasToTempFilePath({
									canvasId: 'scanPhoto',
									success: function(data) {
										console.log('图片地址：')
										console.log(data.tempFilePath)
										that.scanItem.url = data.tempFilePathscanPhoto
										that.$emit('scanItem', that.scanItem)
										if (that.isContinuous) {
											that.scanList.unshift(that.scanItem)
											that.$emit('scanList', that.scanList)
										}
										uni.hideLoading()
									},
									fail: () => {
										uni.hideLoading()
									}
								}, that)
							},
							fail(e) {
								console.log('失败')
								console.log(e)
								uni.hideLoading()
							}
						}, that)
					}
				}, that)
				this.listener.start()
			},
			showDetailFunc(item) {
				this.showDetail = true
				this.showDetailType = true
				this.scanItem = item
			}
		}
	}
</script>
<style lang="scss" scoped>
	@import './css/index.scss';
</style>
